package com.example.microserviceeurekaorder.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;

/**
 * @author liuyulong
 * @create 2022-03-23 16:36
 * @create 2022-三月  星期三
 * @project Microservice-SpringCloud_work2_2022_3_16
 */
@Configuration
public class ServiceInfoUtil implements ApplicationListener<WebServerInitializedEvent> {


    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    private static WebServerInitializedEvent webServerInitializedEvent;

    @Override
    public void onApplicationEvent(WebServerInitializedEvent event) {
        webServerInitializedEvent = event;
        int port = webServerInitializedEvent.getWebServer().getPort();
        logger.info("打印端口: "+port+" webServerInitializedEvent.getWebServer().getPort()");
    }


}
